import {Message, MessageBox, Loading, Notification} from 'element-ui'
let Notice = {}
Notice.install = function (Vue, options) {
    Vue.prototype.$MessageN = {
        error(msg = "未知错误", showClose = true, duration = 2 * 1000) {
            Message({
                message: msg,
                type: 'error',
                showClose: showClose,
                duration: duration
            });
        },
        success(msg = "操作成功", showClose = true, duration = 2 * 1000) {
            Message({
                message: msg,
                type: 'success',
                showClose: showClose,
                duration: duration
            });
        },
        warning(msg = "警告", showClose = true, duration = 2 * 1000) {
            Message({
                message: msg,
                type: 'warning',
                showClose: showClose,
                duration: duration
            });
        },
        tip(msg = "提示", showClose = true, duration = 2 * 1000) {
            Message({
                message: msg,
                showClose: showClose,
                duration: duration
            });
        }
    }

    Vue.prototype.$LoadingN = {
        open() {
            let load = Loading.service({
                fullscreen: true,
                spinner: "el-icon-loading",
                text: '拼命加载',
                lock: true
            });
            return load;
        },
        close() {
            Loading.close();
        }
    }

    Vue.prototype.$NotificationN = {
        open(title, message) {
            Notification({
                title: 'Network Error',
                dangerouslyUseHTMLString: true,
                message: '<strong class="my-notify">请检查 API 是否异常</strong>',
            })
        }
    }
}

export default Notice;